﻿namespace UnityEditor
{
    using System;
    using System.Runtime.CompilerServices;
    using UnityEngine;

    public sealed class VCMessage
    {
        private IntPtr m_thisDummy;

        public VCMessage(string msg)
        {
            this.MsgText = msg;
            this.MsgFormat = Format.Info;
        }

        public VCMessage(string msg, Format fmt)
        {
            this.MsgText = msg;
            this.MsgFormat = fmt;
        }

        public static void Connect(string message)
        {
            Debug.LogError("Version control connection failed:\n" + message);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void Dispose();
        public static void Error(string message)
        {
            Debug.LogError("Version control:\n" + message);
        }

        ~VCMessage()
        {
            this.Dispose();
        }

        public static void Info(string message)
        {
            Debug.Log("Version control:\n" + message);
        }

        public void Show()
        {
            switch (this.MsgFormat)
            {
                case Format.Info:
                    Info(this.MsgText);
                    break;

                case Format.Error:
                    Error(this.MsgText);
                    break;

                case Format.Connect:
                    Connect(this.MsgText);
                    break;
            }
        }

        public string message { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public Format MsgFormat { get; private set; }

        public string MsgText { get; private set; }

        public Severity severity { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public enum Format
        {
            Info,
            Error,
            Connect
        }

        [Flags]
        public enum Severity
        {
            Verbose,
            Info,
            Warning,
            Error,
            Connect
        }
    }
}

